package com.pagepub.expo.manager;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.flex.remoting.RemotingInclude;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.pagepub.expo.dao.AppDictDao;
import com.pagepub.expo.entity.AppDict;
import com.pagepub.expo.entity.CorpTemplate;
import com.pagepub.expo.entity.IdName;


@Service
@Transactional
@RemotingDestination(channels = { "my-amf", "my-secure-amf" })
public class AppDictMng{

	@Autowired
	private AppDictDao appDictDao;


	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<AppDict> findAll() {
		return appDictDao.findAll();
	}
	


	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public int getAppDictsCount(Map<String, String> param){
		return appDictDao.getCount(param);
	}
	
	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<AppDict> findAppDictByPage(int currentPage,int pageSize,Map<String, String> param){
		return appDictDao.findByPage(currentPage, pageSize, param);
	}

	@RemotingInclude
	public AppDict findById(Long id) {
		return appDictDao.findById(id);
	}

	@RemotingInclude
	public AppDict addAppDict(AppDict appDict) {
		appDictDao.insert(appDict);
		return appDictDao.findById(appDict.getId());
	}

	@RemotingInclude
	public Long removeAppDict(Long id) {
		appDictDao.delete(id);
		return id;
	}

	@RemotingInclude
	public AppDict update(AppDict appDict) {
		appDictDao.update(appDict);
		return appDictDao.findById(appDict.getId());
	}
	
	public List<AppDict> getfindByDictCode(String  dictCode){
		return appDictDao.getfindByDictCode(dictCode);
	}
	
	public List<IdName> getIdNamesByDictCode(String  dictCode){
		return appDictDao.findIdNames(dictCode);
	}
}
